#coding: utf-8
from keys import *

class kController:
    def __init__(self, main):
        self.main = main
    
    def eval(self, event):
        "Обработчик событий клавиатуры"
        if self.main.mode=="map":
            if event.key in RIGHT and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player,(1,0))
            if event.key in LEFT and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player, (-1,0))
            if event.key in UP and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player, (0,-1))
            if event.key in DOWN and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player, (0,1))
            if event.key in UPLEFT and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player, (-1,-1))
            if event.key in DOWNLEFT and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player, (-1,1))
            if event.key in UPRIGHT and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player, (1,-1))
            if event.key in DOWNRIGHT and event.type == KEYDOWN: 
                self.main.moveActor(self.main.player,(1,1))
        if self.main.mode=="menu":
            if event.key == K_ESCAPE: self.main.mode = "map"
        if event.key == K_x: self.main.exit()
        if event.key == K_m: self.main.mode = "menu"
        if event.key == K_5: self.main.jumpActor(self.main.player, (0,0))
